<div id="sidebar" class="collapse sidebar-collapse">
	<?php if(isset($article)): ?>
		<h3><?php echo translate("article_categories"); ?></h3>
		<ul class="categories">
			<?php foreach($articleCategories as $articleCategory):?>
				<li><a href="<?php echo site_url()."articles/".$articleCategory["url"]."/"?>">
					<?php echo $articleCategory["name"]; ?> (<?php echo $articleCategory["num_rows"]; ?>)
				</a></li>
				<?php if(isset($articleCategory["children"]) && count($articleCategory["children"]) > 0): ?>
					<ul>
						<?php foreach($articleCategory["children"] as $aCategoryChild): ?>
							<li><a href="<?php echo site_url().$articleCategory["url"]."/".$aCategoryChild["url"]; ?>"><?php echo $aCategoryChild["name"];?></a></li>
						<?php endforeach; ?>
						<li>Lorem ipsum</li>
						<li><a href="#">Dolor sit</a></li>
					</ul>
				<?php endif; ?>
			<?php endforeach; ?>
		</ul>
	<?php else:?>



	<ul>
		<li>
			<a href="<?php echo $site_pages["promotions"]["url"];?>" 
				title="<?php echo $site_pages["promotions"]["name"];?>">
					<?php echo $site_pages["promotions"]["name"];?>
			</a>
		</li>
		<li>
			<a href="<?php echo $site_pages["new_products"]["url"];?>" 
				title="<?php echo $site_pages["new_products"]["name"];?>">
					<?php echo $site_pages["new_products"]["name"];?>
			</a>
		</li>
		<li>
			<a href="<?php echo $site_pages["popular_products"]["url"];?>" 
				title="<?php echo $site_pages["popular_products"]["name"];?>">
					<?php echo $site_pages["popular_products"]["name"];?>
			</a>
		</li>
	</ul>
	<h3><?php echo translate("categories"); ?></h3>
	<ul class="categories">
		<?php foreach($categories as $key => $category): ?>
			<li>
				<?php if($category["num_rows"] > 0): ?>
					<a href="<?php echo site_url().$category["url"]; ?>" title="<?php echo $category["name"]?>">
				<?php endif;?>
					<?php echo $category["name"]?>
				<?php if($category["num_rows"] > 0): ?>
					</a>
				<?php endif; ?>
			</li>
			<?php if(isset($category["children"]) && count($category["children"]) > 0): ?>
				<ul>
					<?php foreach($category["children"] as $k => $subcategory): ?>
						<li>
						<?php if($subcategory["num_rows"] > 0): ?>
							<a href="<?php echo site_url().$subcategory["url"]; ?>" title="<?php echo $subcategory["name"]?>">
						<?php endif;?>
							<?php echo $subcategory["name"]?> (<?php echo $subcategory["num_rows"]; ?>)
						<?php if($subcategory["num_rows"] > 0): ?>
							</a>
						<?php endif; ?>
						</li>
					<?php endforeach; ?>
				</ul>
			<?php endif; ?>
		<?php endforeach; ?>
	</ul>
	<?php if(isset($page["properties"]) && count($page["properties"]) > 0): ?>
		<h3><?php echo translate("filter_products"); ?></h3>
		
		<?php foreach($page["properties"] as $key => $property):?>
			<ul class="filterList">
				<li class="listTitle"><?php echo $property["name"]; ?></li>
				<?php 
					$addClass = "";
					if($property["type"] == 2)
					{
						$addClass="colors";
					}
					$filterURL = $page["url"];
					$selectedValue = null;
					if(isset($page["filters"]) && count($page["filters"]) > 0)
					{
						foreach ($page["filters"] as $key => $filter) 
						{
							if($key != $property["id"])
							{
								$filterURL .= $filter["url"]."/";
							}
							else
							{
								$selectedValue = $filter["property_value_id"];
							}
						}
					}
				?>
				<li class="<?php echo $addClass; ?>">
					<?php foreach($property["values"] as $k => $value): ?>
						
						<?php 
							$addStyle = "";
							if($property["type"] == 2)
							{
								$addStyle="background-color:#".$value["value"];
							}
						?>
						<?php if($selectedValue != null && $selectedValue == $value["id"]): ?>
							<span class="selected" style="<?php echo $addStyle; ?>" title="<?php echo $value["name"]; ?>"><?php echo $value["name"]; ?></span>
							<a class="btn btn-default btn-danger btn-xs removeFilter" href="<?php echo $filterURL; ?>">
								<span class="glyphicon glyphicon-ban-circle"></span>
							</a>
						<?php elseif($selectedValue == null): ?>
							<a style="<?php echo $addStyle; ?>" href="<?php echo $filterURL.$value["url"]."/"; ?>" title="<?php echo $value["name"]; ?>"><?php echo $value["name"]; ?></a>
						<?php endif; ?>
						
					<?php endforeach; ?>
					<?php if($property["type"] == 5): ?>
						<li>
							<a class="lowercase" href="<?php echo $site_pages["size-assistance"]["url"];?>.html" 
								title="<?php echo $site_pages["size-assistance"]["name"];?>">
									<?php echo $site_pages["size-assistance"]["name"];?>
							</a>
						</li>
					<?php endif; ?>
				</li>
			</ul>
		<?php endforeach; ?>
	<?php endif;?>
	

	
	<?php
		$priceFilters = get_price_filters();
		if(count($priceFilters) > 0):
	?>
		<h3><?php echo translate("price"); ?></h3>
		<div class="form-group">
			<select class="form-control" id="priceFilterValue">
				<option value="0"><?php echo translate("select"); ?></option>
				<?php foreach($priceFilters as $priceFilter): ?>
					<?php
						if($priceFilter["type"] == 1)
						{
							$filterText = translate("below") ." ". $priceFilter["price1"];
						}
						elseif($priceFilter["type"] == 2)
						{
							$filterText = translate("above") ." ". $priceFilter["price1"];
						}
						else
						{
							$filterText = $priceFilter["price1"] ." - ".$priceFilter["price2"];
						}
						$filterText .= " " . $settings["currency"];
					?>
					<option value="<?php echo $priceFilter["id"]?>"><?php echo $filterText; ?></option>
				<?php endforeach;?>
			</select>
		</div>
		
	
		<button value="filter" id="priceFliter" class="btn btn-warning"><?php echo translate("filter"); ?></button>
		<?php endif; ?>
	<?php endif; ?>

	<div class="newstab">
		<h3><?php echo translate("newsletter"); ?></h3>
		<p><?php echo translate("newsletter_text"); ?></p>
		<form action="#" class="newsletterForm" method="post">
			<div class="input-group">
		      <input type="text" name="email_address" class="form-control" placeholder="<?php echo translate("email"); ?>"/>
		      <span class="input-group-btn">
		        <button class="btn btn-default btn-warning" type="button"><span class="glyphicon glyphicon-ok-sign"></span></button>
		      </span>
		    </div>
			<div class="clearfix"></div>
		</form>
	</div>

</div>
